package com.example.imtoken.core.utils

import android.widget.ImageView
import com.blankj.utilcode.util.StringUtils
import com.example.imtoken.R

object StatusManageUtils {

    fun statusImageView(image: ImageView, status: Boolean) {
        when (image.id) {
            R.id.item_popular_assets_iv -> {
                if (status) {
                    image.setImageResource(R.drawable.ic_baseline_check_circle_outline_24)
                } else {
                    image.setImageResource(R.drawable.ic_baseline_add_circle_outline_24)
                }
            }
        }
    }

    fun addTokenImageView(image: ImageView, status: Int) {
        val resId = when (status) {
            0 -> {
                R.drawable.ic_baseline_add_token_false_24
            }
            1 -> {
                R.drawable.ic_baseline_add_toen_true_24
            }
            else -> {
                R.drawable.ic_baseline_add_toen_def
            }
        }
        image.setImageResource(resId)
    }

    fun transactionRecord(image: ImageView, type: Int) {
        val resId = when (type) {
            1 -> {
                R.mipmap.src_lib_eui_icon_txsend
            }
            2 -> {
                R.mipmap.src_lib_eui_icon_txreceive
            }
            else -> {
                R.mipmap.src_lib_eui_icon_txfailednew
            }
        }
        image.setImageResource(resId)
    }

    fun transactionDetailsStatus(image: ImageView, status: Int) {
        val resId = when (status) {
            0 -> {
                //待完成
                R.mipmap.src_lib_eui_icon_txpendingnew
            }
            1 -> {
                //成功
                R.mipmap.src_lib_eui_icon_txsuccessnew
            }
            2 -> {
                //失败
                R.mipmap.src_lib_eui_icon_txfailednew
            }
            else -> {
                0
            }
        }
        image.setImageResource(resId)
    }

    fun transactionDetailsStatus(status: Int): String {
        return when (status) {
            0 -> {
                StringUtils.getString(R.string.waitSuccess)
            }
            1 -> {
                StringUtils.getString(R.string.success)
            }
            else -> {
                StringUtils.getString(R.string.transferFail)
            }
        }
    }

}